%
%
% % % % % % % % % % %
%initialize the parameters of ant colony algorithms
load data.txt;
d=data(:,2:3);
g=data(:,4);
m=31; % 蚂蚁数
alpha=1;
belta=4;% 决定tao和miu重要性的参数
lmda=0;
rou=0.9; %衰减系数
q0=0.95;
% 概率
tao0=1/(31*841.04);%初始信息素
Q=1;% 蚂蚁循环一周所释放的信息素
defined_phrm=15.0; % initial pheromone level value
QV=100; % 车辆容量
vehicle_best=round(sum(g)/QV)+1; %所完成任务所需的最少车数
V=40;
% 计算两点的距离
for i=1:32;
for j=1:32;
dist(i,j)=sqrt((d(i,1)-d(j,1))^2+(d(i,2)-d(j,2))^2);
end;
end;
%给tao miu赋初值
for i=1:32;
for j=1:32;
if i~=j;
%s(i,j)=dist(i,1)+dist(1,j)-dist(i,j);
tao(i,j)=defined_phrm;
miu(i,j)=1/dist(i,j);
end;
end;
end;
for k=1:32;
for k=1:32;
deltao(i,j)=0;
end;
end;
best_c
%
% the procedure of ant colony algorithm for VRP
%花了点时间写的,但是有点问题,实在找不到,欢迎大家交流,共同进步
% % % % % % % % % % %
%initialize the parameters of ant colony algorithms
load data.txt;
d=data(:,2:3);
g=data(:,4);
m=31; % 蚂蚁数
alpha=1;
belta=4;% 决定tao和miu重要性的参数
lmda=0;
rou=0.9; %衰减系数
q0=0.95;
% 概率
tao0=1/(31*841.04);%初始信息素
Q=1;% 蚂蚁循环一周所释放的信息素
defined_phrm=15.0; % initial pheromone level value
QV=100; % 车辆容量
vehicle_best=round(sum(g)/QV)+1; %所完成任务所需的最少车数
V=40;
% 计算两点的距离
for i=1:32;
for j=1:32;
dist(i,j)=sqrt((d(i,1)-d(j,1))^2+(d(i,2)-d(j,2))^2);
end;
end;
%给tao miu赋初值
for i=1:32;
for j=1:32;
if i~=j;
%s(i,j)=dist(i,1)+dist(1,j)-dist(i,j);
tao(i,j)=defined_phrm;
miu(i,j)=1/dist(i,j);
end;
end;
end;
for k=1:32;
for k=1:32;
deltao(i,j)=0;
end;
end;
best_c